package conson.tech.manage.message.service.impl;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import conson.tech.manage.common.util.EntityUtils;
import conson.tech.manage.message.entity.pojo.MessageSendLog;
import conson.tech.manage.message.entity.vo.MessageSendLogVo;
import conson.tech.manage.message.entity.vo.PageVo;
import conson.tech.manage.message.mapper.MessageSendLogMapper;
import conson.tech.manage.message.service.MessageSendLogService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * ClassName: MessageSendLogServiceImpl
 * Description:
 * Author: HXL
 * Date: 2020/4/22 9:50 上午
 * Version: 1.0
 */
@Service("messageSendLogService")
public class MessageSendLogServiceImpl implements MessageSendLogService {
    @Autowired
    private MessageSendLogMapper messageSendLogMapper;
    @Override
    @Transactional
    public int createSendLog(MessageSendLogVo vo) {
        //MessageConfigDTO config = new MessageConfigDTO();
        MessageSendLog config = new MessageSendLog();
        vo.setUpdatedTime(new Date());
        BeanUtils.copyProperties(vo, config);
        return messageSendLogMapper.insert(config);
    }

    @Override
    public Page<MessageSendLogVo> querySendPage(PageVo vo) {
        Page<MessageSendLog> page = new Page();
        page.setCurrent(vo.getPageIndex());
        page.setSize(vo.getPageSize());
        Page<MessageSendLog> dtoPage = messageSendLogMapper.querySendPage(page,vo.getConfigId());
        Page<MessageSendLogVo> adPage = new Page<>();
        if (dtoPage != null) {
            return EntityUtils.pageToPage(dtoPage, MessageSendLogVo.class);
        }
        return adPage;
    }
    
    
}
